#include "buildsettings.h"
#include "list.h"

#ifndef _HASHTABLE_
#define _HASHTABLE_
typedef struct structHashTablePair HashTablePair;
typedef struct structHashTable HashTable;

//! Defines a key-value pair in a hash table
/*!
  Not intended to be used externally
*/
struct structHashTablePair
{
	//! String key
	char *Key;
	//! Generic memory pointer as a value
	void *Value;
	//! Pointer to the next pair in the list. Null when not used
	struct structHashTablePair *Next;
};

//! Defines a hash table
struct structHashTable
{
	//! Size of the hash table
	int Size;
	//! Dynamically allocated array of pairs
	void **Pairs;


	int (*Set)(struct structHashTable *ht, char *key, void *value);
	void *(*Get)(struct structHashTable *ht, char *key);
	List (*GetKeys)(struct structHashTable *table);
};

struct structHashTable new_HashTable(int size);
void destroy_HashTable(struct structHashTable *ht);
int hashtable_set(struct structHashTable *ht, char *key, void *value);
void *hashtable_get(struct structHashTable *table, char *key);
List hashtable_getkeys(struct structHashTable *table);

#endif
